import { mnueData, ExperienceList } from '@/utils/data.ts'
import { MenuItem } from '@/types/index.ts'

export const getMenuData = () => {
  return Promise.resolve().then((data) => {
    return mnueData
  })
}

const getRouteId = (data: MenuItem[]): MenuItem => {
  const pathname = window.location.pathname
  for (const item of data) {
    if (item.children) {
      return getRouteId(item.children as MenuItem[])
    } else {
      if (item.route === pathname) {
        return item
      } else {
        continue
      }
    }
  }
  return {
    id: '',
    name: '',
  }
}
export const getmenuActive = (): MenuItem => {
  return getRouteId(mnueData)
}

export const getExperience = () => {
  return Promise.resolve().then((data) => {
    return ExperienceList
  })
}
